library(dplyr)
library(tidyr)
library(foreign)

# 2012 ANES has too many variables to be opened in Stata
# This code selects the variables needed for the analysis
# and saves them in a new dataset "anes_timeseries_2012_slim.dta" 

t12<-read.dta("*/Replication files/anes_timeseries_2012_Stata12.dta")


t12_alt <- select(t12,
cses_satisdem,resent_slavery,resent_workway,resent_deserve,resent_try,presvote2012_x,prevote_intpres,prevote_intpreswho,incgroup_prepost_x,dem_age_r_x,dem_edu,dem_racecps_asian,dem_racecps_black,dem_racecps_native,dem_racecps_othrace,dem_racecps_pacif,dem_racecps_racedkrf,dem_racecps_white,gender_respondent_x,interest_following,econ_ecpast_x,econ_ecpast,libcpre_self,postvote_presvtwho,caseid,mode, weight_ftf

)

write.dta(t12_alt,"*/Replication files/anes_timeseries_2012_slim_rresentment.dta")